package com.dwxt.mall.admin.controller;

import com.dwxt.common.annotation.ValidateFiled;
import com.dwxt.common.annotation.ValidateGroup;
import com.dwxt.common.base.BaseResult;
import com.dwxt.mall.admin.service.TrainHallServiceAdmin;
import com.dwxt.mall.entity.TrainHall;
import com.dwxt.mall.entity.dto.TrainHallDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

@RequestMapping("/mall/hall")
@RestController
public class TrainHallControllerAdmin {

    @Autowired
    private TrainHallServiceAdmin trainHallServiceAdmin;

    @RequestMapping("/createOrUpdateHall")
    @ValidateGroup(fileds = {
            @ValidateFiled(index = 0, filedName = "phone", regStr = "^[0-9]*$")
    })
    public BaseResult createOrUpdateHall(TrainHallDTO trainHallDTO) {
        return trainHallServiceAdmin.createOrUpdateHall(trainHallDTO);
    }


    @RequestMapping("/selectHallByKey")
    public BaseResult selectHallByKey(Integer id) {
        TrainHall trainHall = trainHallServiceAdmin.selectHallByKey(id);
        return BaseResult.ok(trainHall);
    }

    @RequestMapping("/delete")
    public BaseResult delete(Integer[] id) {
        trainHallServiceAdmin.delete(id);
        return BaseResult.ok();
    }
}
